© Zühlke APAC SWEX+DX 2024
© Zühlke APAC SWEX+DX 2024
ingestion
branch of the template repobackend
folder as a source root in PyCharmbackend
is listed as a Source foldergit clone -b ingestion https://xxx@dev.azure.com/ZuhlkeAsia/RAG%20Workshop/_git/rag-template
pip install -r requirements.txt
pip install -r requirements-dev.txt
python -m nltk.downloader popular
# In case you encounter SSO issue when initiaising NLTK
export SSL_CERT_FILE=$(python -m certifi)
sudo sh "Install Certificates.command"
© Zühlke APAC SWEX+DX 2024
© Zühlke APAC SWEX+DX 2024
© Zühlke APAC SWEX+DX 2024
© Zühlke APAC SWEX+DX 2024
© Zühlke APAC SWEX+DX 2024
Implement a Python function to generate embedding for input text by invoking an Azure OpenAI service using embedding
client.
Use the library: openai~=1.46.1 or azure-ai-inference==1.0.0b5
© Zühlke APAC SWEX+DX 2024
© Zühlke APAC SWEX+DX 2024
Help me to write a Python function that queries the Azure AI Search with question embedding to retrieve the top 3 most
relevant document chunks.
Use library: azure-search-documents~=11.5.1
© Zühlke APAC SWEX+DX 2024
© Zühlke APAC SWEX+DX 2024
© Zühlke APAC SWEX+DX 2024
Refactor my Python app code to maintain a history of user questions.
Write a new function that creates a detailed prompt by combining the user question with the
retrieved document chunks.
© Zühlke APAC SWEX+DX 2024
© Zühlke APAC SWEX+DX 2024
system_prompt = {
"role": "system",
"content": "You are an AI Assistant helping to compare different health insurance policies. "
"Be brief in your answers. "
"Answer ONLY with the facts listed in the list of sources below. "
"If there isn't enough information below, say you don't know. "
"Do not generate answers that don't use the sources below. "
"Each source has a name followed by colon and the actual information, include the source name for each fact you use. "
"Use square brackets to reference the source, for example [info1.txt]."
}
© Zühlke APAC SWEX+DX 2024
© Zühlke APAC SWEX+DX 2024
Implement a Python function that takes the complete prompt and invoke Azure OpenAI Model using text completion client.
Ensure
Use the library: openai~=1.46.1 or azure-ai-inference==1.0.0b5
© Zühlke APAC SWEX+DX 2024